<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/21
 * Time: 20:27
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Traits\VipCardRuleTrait;
use App\Http\Logics\MiniProgramAdmin\VipCardRuleLogic;
use App\Http\Controllers\BaseController;
class VipCardRuleController extends BaseController
{
    use VipCardRuleTrait;
    /**
     * @SWG\Post(
     *     path="/vipCardRule/create",
     *     tags={"VipCardRule"},
     *     description="新建会员卡打折规则",
     *     operationId="updateVipCardRule",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="规则名称",
     *         required=true,
     *         type="string"
     *     ),
     *      @SWG\Parameter(
     *         name="vip_card_rule_value_list_str",
     *         in="query",
     *         description="规则值列表字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createVipCardRule()
    {
        $name = $this->name;
        $vip_card_rule_value_list_str = $this->vip_card_rule_value_list_str;
        $loginSession = $this->loginSession;
        $data = [
            'name' => $name,
            'vip_card_rule_value_list_str' => $vip_card_rule_value_list_str,
            'loginSession' => $loginSession
        ];
        $response = VipCardRuleLogic::createVipCardRule($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/vipCardRule/update",
     *     tags={"VipCardRule"},
     *     description="更新会员卡打折规则",
     *     operationId="updateVipCardRule",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_rule_id",
     *         in="query",
     *         description="会员卡规则ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="规则名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_rule_value_list_str",
     *         in="query",
     *         description="会员卡规则值列表字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateVipCardRule()
    {
        $vip_card_rule_id = $this->vip_card_rule_id;
        $name = $this->name;
        $vip_card_rule_value_list_str = $this->vip_card_rule_value_list_str;
        $data = [
            'vip_card_rule_id' => $vip_card_rule_id,
            'name' => $name,
            'vip_card_rule_value_list_str' => $vip_card_rule_value_list_str
        ];
        $response = VipCardRuleLogic::updateVipCardRule($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCardRule/list",
     *     tags={"VipCardRule"},
     *     description="获取会员卡打折规则列表",
     *     operationId="getVipCardRuleList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardRuleList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = VipCardRuleLogic::getVipCardRuleList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCardRule/detail",
     *     tags={"VipCardRule"},
     *     description="获取会员卡打折规则列表",
     *     operationId="getVipCardRuleDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_rule_id",
     *         in="query",
     *         description="VIP卡规则ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardRuleDetail()
    {
        $vip_card_rule_id = $this->vip_card_rule_id;
        $data = [
            'vip_card_rule_id' => $vip_card_rule_id
        ];
        $response = VipCardRuleLogic::getVipCardRuleDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/vipCardRule/delete",
     *     tags={"VipCardRule"},
     *     description="删除会员卡打折规则",
     *     operationId="deleteVipCardRule",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_rule_id",
     *         in="query",
     *         description="VIP卡规则ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deleteVipCardRule()
    {
        $vip_card_rule_id = $this->vip_card_rule_id;
        $data = [
            'vip_card_rule_id' => $vip_card_rule_id
        ];
        $response = VipCardRuleLogic::deleteVipCardRule($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}